package com.chase.springboot.controller;

import com.chase.springboot.model.Role;
import com.chase.springboot.model.User;
import com.chase.springboot.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api("用户管理")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation(("添加用户"))
    @PostMapping("/user")
    public boolean insertUser(@RequestBody User user){
        return userService.addUser(user);
    }

    @ApiOperation(("删除用户"))
    @DeleteMapping("/user/{id}")
    public boolean deleteUser(@PathVariable("id")Integer id){
        return userService.deleteUserById(id);
    }

//    @ApiOperation(("获取用户的角色"))
//    @GetMapping("/user/role/{id}")
//    public List<Role> selectRoleByUserId(@PathVariable("id")Integer id){
//        return userService.selectRoleByUserId(id);
//    }
//
//    @ApiOperation(("添加用户的角色"))
//    @PostMapping("/user/role/{id}")
//    public boolean addRoleByUserId(@RequestBody Role role){
//        return userService.addRoleByUserId(role);
//    }
//
//    @ApiOperation(("删除用户的角色"))
//    @DeleteMapping("/user/role/{id}")
//    public boolean deleteRoleByUserId(@PathVariable("id")Integer id){
//        return userService.deleteRoleByUserId(id);
//    }
}
